const express = require('express');
const bodyParser = require('body-parser');
// 解决跨域
const cors = require('cors');

const app = express();

app.use(bodyParser.json());
app.use(cors());

// 定义GET请求的路由
app.get('/login', (req, res) => {
    res.send('Hello World!');
});

// 定义POST请求的路由
app.post('/login', (req, res) => {
    console.log(req.query);
    if (req.query.userName == 'admin' && req.query.passWord == '123456') {
        res.send({ werweR: 3241234123, werqwer: 5345234 });
    } else {
        res.send({ werweR: false});
    }
});

// 启动服务器
app.listen(3000, () => {
    console.log('Server started on port 3000');
});
